package com.dao.impl;

import com.dao.ShopCartDao;
import com.pojo.ShopCart;
import com.utils.JDBCUtil;

public class ShopCartDaoImpl implements ShopCartDao {
    /**
     * 根据用户ID获取该用户是否有购物车
     * @param userID
     * @return
     */
    @Override
    public ShopCart selectByUserID(String userID) {
        return JDBCUtil.queryOne(ShopCart.class,"select * from s_shop_cart where user_id = ?",userID);
    }

    /**
     * 为用户创建购物车
     * @param shopCart
     * @return
     */
    @Override
    public int addShopCar(ShopCart shopCart) {
        return JDBCUtil.update("insert into s_shop_cart values(?,?,?)",shopCart.getId(),shopCart.getCartId(),shopCart.getUserId());
    }
}
